package com.goodflower.goodflower.creat_flower;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.goodflower.goodflower.R;

public class Creat_flower_three extends AppCompatActivity {
    private EditText creat_flower_at;
    private Button btn_creat_flower_three_next;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.creat_flower_three);
        //找到控件
        creat_flower_at = (EditText)findViewById(R.id.creat_flower_at);
        btn_creat_flower_three_next = (Button)findViewById(R.id.btn_creat_flower_three_next);
        //接收上一个页面的数据
        Intent from_two_intent = getIntent();
        final String flower_mac = from_two_intent.getStringExtra("flower_mac");
        final String flower_id = from_two_intent.getStringExtra("flower_id");
        final String flower_name = from_two_intent.getStringExtra("flower_name");
        final String mac_flower_name = from_two_intent.getStringExtra("mac_flower_name");
        //下一页按钮点击事件
        btn_creat_flower_three_next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(creat_flower_at.getText().toString().isEmpty()){
                    Toast.makeText(v.getContext(),"亲,您必须设置智能模式下的土壤湿度临界值",Toast.LENGTH_LONG).show();
                }else {
                    Intent creat_flower_three_intent = new Intent(Creat_flower_three.this, Creat_flower_four.class);
                    creat_flower_three_intent.putExtra("flower_at",creat_flower_at.getText().toString());
                    creat_flower_three_intent.putExtra("flower_mac",flower_mac);
                    creat_flower_three_intent.putExtra("flower_id",flower_id);
                    creat_flower_three_intent.putExtra("flower_name",flower_name);
                    creat_flower_three_intent.putExtra("mac_flower_name",mac_flower_name);
                    startActivity(creat_flower_three_intent);
                }
            }
        });
    }
}
